import React, {Component} from 'react'
import { withRouter } from 'react-router-dom'

import LoadingComponent from './LoadingComponent'

class LazyLoad extends Component {
  state = {
    LoadOver: null
  }
  componentWillMount() {
    this.props.Loading(c => {
      this.setState({
        LoadOver: withRouter(c.default)
      })
    })
  }
 
  render() {
    let {LoadOver} = this.state;
    return (
      LoadOver ? <LoadOver/> : <LoadingComponent/>
    )
  }
}

export default LazyLoad